package com.kusen.village.raise.service.impl;

import com.kusen.village.raise.entity.Product;
import com.kusen.village.raise.mapper.ProductMapper;
import com.kusen.village.raise.service.ProductService;
import com.kusen.village.raise.util.PageList;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @description: 商品服务实现类
 * @author: ghl
 * @create: 2021-11-30 19:51
 **/
@Service
public class ProductServiceImpl implements ProductService {
    @Autowired
    private ProductMapper productMapper;
    @Override
    public List<Product> getProductList() {
        return productMapper.getProductList();
    }

    /**
     * 分页获取商品数据
     * @param pageList
     */
    @Override
    public void getProductListByLimit(PageList<Product> pageList) {
        List<Product> result=productMapper.getProductListByLimit(pageList);
        pageList.setRows(result);
        pageList.setTotal(productMapper.getProductListByLimitCount(pageList));
    }

    /**
     * 添加商品数据
     * @param product
     * @return
     */
    @Override
    public int saveProduct(Product product) {
        return productMapper.saveProduct(product);
    }

    /**
     * 修改商品信息
     * @param product
     * @return
     */
    @Override
    public int updateProduct(Product product) {
        return productMapper.updateProduct(product);
    }

    @Override
    public int deleteProductById(Integer id) {
       return productMapper.deleteProductById(id);
    }
}
